﻿using RefactorThis.GraphDiff.Attributes;
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using TanmiaGrp.Basis.Core;

namespace TanmiaGrp.GeneralLedger.Core
{
    public partial class VoucherDetail : BusinessObject
    {
        private int voucherDetailID;
        private double credit;
        private double debit;
        private string description;
        private Account account;

        [DatabaseGenerated(System.ComponentModel.DataAnnotations.Schema.DatabaseGeneratedOption.Identity)]
        public int VoucherDetailID
        {
            get { return voucherDetailID; }
            set
            {
                if (voucherDetailID != value)
                {
                    voucherDetailID = value;
                    RaisePropertyChanged(() => VoucherDetailID);
                }
            }
        }

        [Required]
        [Associated, ForeignKey("AccountID")]
        public Account Account
        {
            get { return account; }
            set
            {
                if (account != value)
                {
                    account = value;
                    RaisePropertyChanged(() => Account);
                }
            }
        }

        [Associated, ForeignKey("VoucherID")]
        public Voucher Voucher { get; set; }

        public int AccountID { get; set; }

        public int VoucherID { get; set; }

        [Range(0, double.MaxValue)]
        public double Debit
        {
            get { return debit; }
            set
            {
                if (debit != value)
                {
                    debit = value;
                    RaisePropertyChanged(() => Debit);
                }
            }
        }

        [Range(0, double.MaxValue)]
        public double Credit
        {
            get { return credit; }
            set
            {
                if (credit != value)
                {
                    credit = value;
                    RaisePropertyChanged(() => Credit);
                }
            }
        }

        [MaxLength(255)]
        public string Description
        {
            get { return description; }
            set
            {
                if (description != value)
                {
                    description = value;
                    RaisePropertyChanged(() => Description);
                }
            }
        }
    }
}
